require(['jquery', 'cookie', 'app',"lay"], function ($) {
    layui.use(['layer', 'carousel', 'element'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var carousel = layui.carousel;
        var device = layui.device();
        // 渲染轮播
        carousel.render({
            elem: '#workplaceNewsCarousel',
            width: '100%',
            height: '70px',
            arrow: 'none',
            autoplay: true,
            trigger: device.ios || device.android ? 'click' : 'hover',
            anim: 'fade'
        });

    });
    require(['vue'], function (Vue) {
        var dic = new Vue({
            el: ".vue-box"
            , data: {
                menu: [],
                that: {

                },
            }
            , created: function () {
               this.that = playGet("/v2/api/info").data
            }
            , methods: {
                loadPage: function () {
                    load();
                    layui.use(["layer", "admin", 'index'], function () {
                        var b = layui.layer;
                        var $ = layui.jquery, index = layui.index, admin = layui.admin;
                        admin.changeTheme(localStorage.getItem("theme"));
                        // 默认加载主页
                        index.loadHome({
                            menuPath: '/view/workplace',
                            menuName: '<i class="layui-icon layui-icon-home"></i>'
                        });
                        if (localStorage.getItem("theme") == null) {
                            localStorage.setItem("theme", "theme-colorful");
                            admin.changeTheme("theme-colorful");
                        }
                    })
                },
                loginOut: function () {
                    playGet("/loginout", "", "");
                    window.location.href = "/login";
                },
                openAdd: function () {
                    this.that = JSON.parse(localStorage.getItem("userInfo"));
                    alrYN($("#admins"), function () {
                        var jon = dic.that;
                        var ret = playPut("/v1/api/users/save", "", JSON.stringify(jon));
                        alr(ret.msg);
                    }, function () {

                    }, function () {

                    }, "修改信息", 1, ["600px", "350px"]);
                }
            }
        });
    })
});